package com.summer.springboot.timing.task.scheduler;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class ScheduledJobs {

    @SneakyThrows
    @Scheduled(fixedDelay = 5000)
    public void fixedDelayJob() {
        log.info("fixedDelay start : " + new Date());
        Thread.sleep(6000);
        log.info("fixedDelay end : " + new Date());
    }

    @SneakyThrows
    @Scheduled(fixedRate = 5000)
    public void fixedRateJob() {
        log.info("fixedRate start : " + new Date());
        Thread.sleep(6000);
        log.info("fixedRate end : " + new Date());
    }

    @SneakyThrows
    @Scheduled(cron = "0/5 * * * * ? ")
    public void cron() {
        log.info("cron running : " + new Date());
    }

}
